package com.sia.springcloud.controller;


import com.sia.springcloud.service.IPointService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 通信协议变量表 前端控制器
 * </p>
 *
 * @author Sirius
 * @since 2021-12-27
 */
@Slf4j
@RestController
@RequestMapping("//pointController")
public class PointController {


    @Resource
    private IPointService pointService;

    /**
     * 插入点位
     *
     * @param request protocolName和对应协议点位信息
     * @return
     */
    @RequestMapping("/insertPoint")
    public String insertPoint(HttpServletRequest request) {
        log.info("插入点位");
        return pointService.insertPoint(request);
    }

    /**
     * 分页查询点位
     *
     * @param request protocolName 和 start、limit、设备名
     * @return
     */
    @RequestMapping("/queryPoint")
    public String queryPoint(HttpServletRequest request) {
        log.info("查询点位");
        return pointService.queryPoint(request);
    }

    /**
     * 删除点位
     *
     * @param request ProtocolName和一个pointId集合
     * @return
     */
    @RequestMapping("/deletePoint")
    public String deletePoint(HttpServletRequest request) {
        log.info("删除点位");
        return pointService.deletePoint(request);
    }

    /**
     * 更新点位信息，将对应协议的点位信息传过来
     *
     * @param request protocolName和对应协议点位信息
     * @return
     */
    @RequestMapping("/updatePoint")
    public String updatePoint(HttpServletRequest request) {
        log.info("更新点位");
        return pointService.updatePoint(request);
    }


    /**
     * 获取设备表单格式
     *
     * @param request
     * @return
     */
    @RequestMapping("/tableStructure")
    public String tableStructure(HttpServletRequest request) {
        log.info("获取点位表结构");
        return pointService.tableStructure(request);
    }

}
